package com.common.entity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;

/**
 * 统一定义id的entity基类.
 *
 * @author Administrator
 */
@Data
@MappedSuperclass
public abstract class IdStrEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(generator = "customGenerationId")
    @GenericGenerator(name = "customGenerationId", strategy = "com.common.entity.CustomGenerationId",
            parameters = {@Parameter(name = "idPrefix", value = "USER")})
    @Column(length = 8)
    protected String id;

}
